// See https://sequelize.org/master/manual/model-basics.html
// for more of what you can do here.
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;

module.exports = function (app) {
  const sequelizeClient = app.get('sequelizeClient');
  const goods = sequelizeClient.define('goods', {
    name:  DataTypes.STRING,          // 商品名称
    number: DataTypes.INTEGER,        // 当前数量
    inMoney: DataTypes.DECIMAL(10,2), // 入库
    goodno: DataTypes.STRING,         // 商品编号
    unit:  DataTypes.STRING,          // 单位
    actionUser: DataTypes.INTEGER,    // 操作员id
    deadLine:  DataTypes.DATE,        // 到期时间
    suply: DataTypes.STRING,          // 供应商
    cover: DataTypes.STRING,          // 商品的图片
    desc: DataTypes.TEXT('long'),     // 商品描述  DataTypes.TEXT('long')长字符串一般用在文章详情当前
  }, {
    hooks: {
      beforeCount(options) {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line no-unused-vars
  goods.associate = function (models) {
    // Define associations here
    // See https://sequelize.org/master/manual/assocs.html
  };

  return goods;
};
